using System;
using System.Windows.Input;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Phoenix;
using Phoenix.Commands;
using Phoenix.Framework;

namespace PhoenixDebugPhoneApp.Home
{
    public class IndexViewModel : ViewModelBase
    {
        public IndexViewModel()
        {
            NavigateAwayCommand = new DelegateCommand(NavigateAway);
            DeepLinkCommand = new DelegateCommand(DeepLink);
        }

        void DeepLink()
        {
            var deepLink = Controller<HomeController>().DeepLinkFor(c => c.DeepLink, new QueryStringArgumentsCollection());
            ShellTile.Create(deepLink, new StandardTileData
                                           {
                                               BackgroundImage = new Uri("/ApplicationIcon.png", UriKind.Relative),
                                               Title = "Phoenix Deep Link"
                                           });
        }

        void NavigateAway()
        {
            ((PhoneApplicationPage) Context.Host.HostTarget.ContentHost).NavigationService
                .Navigate(new Uri("/NavigateAway.xaml", UriKind.Relative));
        }

        public ICommand NavigateAwayCommand { get; private set; }

        public ICommand DeepLinkCommand { get; private set; }

        protected override void OnActivated()
        {
            
        }

        protected override void OnDeactivated()
        {
            
        }
    }
}